﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HotelManger2012
{
    public partial class Form5ZajetePokoje : Form
    {
        Form1Manager form = new Form1Manager();
        List<int> pokoje = new List<int>();
        public Form5ZajetePokoje()
        {
            InitializeComponent();
            for (int i = 0; i < Form1Manager.klienci.Count; i++)
            {      
                pokoje.Add(Form1Manager.klienci[i].getNr_pokoju());
            }
            pokoje.Sort();
            for (int i = 0; i < pokoje.Count; i++)
            {              
                listBox1.Items.Add("nr pokoju : " +pokoje[i]);
            }
            if (listBox1.Items.Count > 0)
            {
                string[] nrpokoju;
                nrpokoju = listBox1.Items[0].ToString().Split(':');
                for (int i = 0; i < Form1Manager.klienci.Count; i++)
                {
                    if (Form1Manager.klienci[i].getNr_pokoju() == int.Parse(nrpokoju[1]))
                    {
                        label4.Text = Form1Manager.klienci[i].getImie();
                        label5.Text = Form1Manager.klienci[i].getNazwisko();
                    }
                }
            listBox1.SelectedIndex = 0;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void Form5ZajetePokoje_FormClosed_1(object sender, FormClosedEventArgs e)
        {
            this.Hide();
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox1.Items.Count > 0)
            {
                string[] nrpokoju;
                nrpokoju = listBox1.Items[listBox1.SelectedIndex].ToString().Split(':');
                for (int i = 0; i < Form1Manager.klienci.Count; i++)
                {
                    if (Form1Manager.klienci[i].getNr_pokoju() == int.Parse(nrpokoju[1]))
                    {
                        label4.Text = Form1Manager.klienci[i].getImie();
                        label5.Text = Form1Manager.klienci[i].getNazwisko();
                    }
                }

            }
        }

        private void Form5ZajetePokoje_Load(object sender, EventArgs e)
        {

        }
    }
}
